def get_per_fifthpow_sum(d):
    res = 0
    while d != 0:
        res += pow(d % 10, 5)
        d //= 10
    return res


if __name__ == '__main__':
    fin_res = 0
    for i in range(10, 999999):
        if i == get_per_fifthpow_sum(i):
            fin_res += i
    print(fin_res)
